export default {
  // 判断是否套餐生效    1是续订生效 2是立即生效
  mainPack (state, combo) {
    // state 1-没有主套餐 2-主套餐已到期流量未用完 3-主套餐已到期流量已用完 4-主套餐未到期流量未用完 5-主套餐未到期流量用完
    let active = ''
    if (['1', '2', '3'].includes(state + '')) {
      active = 2
    }
    if (['4', '5'].includes(state + '')) {
      active = 1
    }

    if (!combo || combo == 'overlay') {
      active = 2
    }
    return active
  },
  // 处理套餐显示的名字
  nameFn (name) {
    var showName = name
    if (showName.charAt(showName.length - 1) == ')' || showName.charAt(showName.length - 1) == '）') {
      let patt = /\(|（+[A-Za-z]+）|\)/
      let rp = showName.match(patt)
      console.log(rp)
      showName = showName.replace(rp, '')

      // 方法2
      // showName = showName.replace(/\(|（/g, function (name) {
      //   return '('
      // })
      // showName = showName.substring(0, showName.lastIndexOf('('))
    }
    return showName
  }
}
